package org.darkforest.model;

import org.darkforest.common.util.DateUtil;
import org.darkforest.common.util.Page;

import java.math.BigDecimal;

public class PMiaosha extends Page<PMiaosha> {
    private Integer msId;

    private String msName;

    private String msTitle;

    private String msExplain;

    private Integer quotaId;

    private Integer startTime;

    private Integer endTime;

    private Integer memberId;

    private Integer storeId;

    private String memberName;

    private String storeName;

    private Byte maxLimit;

    private Integer msAmount;

    private String msQuestion;

    private String msAnswer;

    private Integer goodsId;

    private String goodsName;

    private BigDecimal msPrice;

    private String goodsImage;

    private Byte state;

    public String startTimeStr;

    public String endTimeStr;

    public BigDecimal goodsPrice;          //显示价格，取商品的市场价

    public BigDecimal goodsOrgPrice;        //原有售价

    private String msActiveImage;

    private Integer validAmount;        //剩余可秒杀数量
    public Integer getPurchased() {
        return purchased;
    }

    private Integer gcId;               //商品最底层分类id，生成订单时使用

    public Integer getValidAmount() {

        return validAmount==null?msAmount:validAmount;
    }

    public void setValidAmount(Integer validAmount) {

        this.validAmount = validAmount;
    }

    public Integer getYunFee(){
        return msPrice.intValue()>=99?0:10;
    }

    public Integer getTotal(){
        return msPrice.add(new BigDecimal(getYunFee())).intValue();
    }

    public void setPurchased(Integer purchased) {
        this.purchased = purchased;
    }

    private Integer purchased;

    public Integer getNow(){
        return DateUtil.unixTimeStampInt().intValue();
    }

    public BigDecimal getDiscount(){
        BigDecimal discount = msPrice.multiply(new BigDecimal(10)).divide(goodsPrice,1,BigDecimal.ROUND_HALF_EVEN);
//        discount.setScale(1,BigDecimal.ROUND_HALF_UP);
        return discount;
    }

    public String getMsActiveImage() {
        return msActiveImage;
    }

    public void setMsActiveImage(String msActiveImage) {
        this.msActiveImage = msActiveImage;
    }

    public BigDecimal getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(BigDecimal goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public String getStartTimeStr() {
        return startTimeStr;
    }

    public void setStartTimeStr(String startTimeStr) {
        this.startTimeStr = startTimeStr;
    }

    public String getEndTimeStr() {
        return endTimeStr;
    }

    public void setEndTimeStr(String endTimeStr) {
        this.endTimeStr = endTimeStr;
    }

    public Integer getMsId() {
        return msId;
    }

    public void setMsId(Integer msId) {
        this.msId = msId;
    }

    public String getMsName() {
        return msName;
    }

    public void setMsName(String msName) {
        this.msName = msName == null ? null : msName.trim();
    }

    public String getMsTitle() {
        return msTitle;
    }

    public void setMsTitle(String msTitle) {
        this.msTitle = msTitle == null ? null : msTitle.trim();
    }

    public String getMsExplain() {
        return msExplain;
    }

    public void setMsExplain(String msExplain) {
        this.msExplain = msExplain == null ? null : msExplain.trim();
    }

    public Integer getQuotaId() {
        return quotaId;
    }

    public void setQuotaId(Integer quotaId) {
        this.quotaId = quotaId;
    }

    public Integer getStartTime() {
        return startTime;
    }

    public void setStartTime(Integer startTime) {
        this.startTime = startTime;
    }

    public Integer getEndTime() {
        return endTime;
    }

    public void setEndTime(Integer endTime) {
        this.endTime = endTime;
    }

    public Integer getMemberId() {
        return memberId;
    }

    public void setMemberId(Integer memberId) {
        this.memberId = memberId;
    }

    public Integer getStoreId() {
        return storeId;
    }

    public void setStoreId(Integer storeId) {
        this.storeId = storeId;
    }

    public String getMemberName() {
        return memberName;
    }

    public void setMemberName(String memberName) {
        this.memberName = memberName == null ? null : memberName.trim();
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName == null ? null : storeName.trim();
    }

    public Byte getMaxLimit() {
        return maxLimit;
    }

    public void setMaxLimit(Byte maxLimit) {
        this.maxLimit = maxLimit;
    }

    public Integer getMsAmount() {
        return msAmount;
    }

    public void setMsAmount(Integer msAmount) {
        this.msAmount = msAmount;
    }

    public String getMsQuestion() {
        return msQuestion;
    }

    public void setMsQuestion(String msQuestion) {
        this.msQuestion = msQuestion == null ? null : msQuestion.trim();
    }

    public String getMsAnswer() {
        return msAnswer;
    }

    public void setMsAnswer(String msAnswer) {
        this.msAnswer = msAnswer == null ? null : msAnswer.trim();
    }

    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName == null ? null : goodsName.trim();
    }

    public BigDecimal getMsPrice() {
        return msPrice;
    }

    public void setMsPrice(BigDecimal msPrice) {
        this.msPrice = msPrice;
    }

    public String getGoodsImage() {
        return goodsImage;
    }

    public void setGoodsImage(String goodsImage) {
        this.goodsImage = goodsImage == null ? null : goodsImage.trim();
    }

    public Byte getState() {
        return state;
    }

    public void setState(Byte state) {
        this.state = state;
    }

    public Integer getGcId() {
        return gcId;
    }

    public void setGcId(Integer gcId) {
        this.gcId = gcId;
    }

    public BigDecimal getGoodsOrgPrice() {
        return goodsOrgPrice;
    }

    public void setGoodsOrgPrice(BigDecimal goodsOrgPrice) {
        this.goodsOrgPrice = goodsOrgPrice;
    }

    public String getStateDes(){
        switch (this.state){
            case 0:return "已结束";
            case 1:return "正常";
            case 2:return "取消";
            default: return "未知状态";
        }
    }
}